package cn.cjxy.web.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 基于注解配置
 * @author huangjie
 * @date 2025/9/26
 */
@WebServlet(name = "helloservlet2",urlPatterns = "/hello2")
public class HelloServlet2 extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置响应编码
        resp.setContentType("text/html;charset=utf-8");
        //往网页输出信息
        //获取打印流对象
        resp.getWriter().print("<h1>hello tomcat----基于注解配置</h1>");
    }
}
